//
//  LaunchImageViewController.m
//  copyrightTrading
//
//  Created by edz on 2020/10/29.
//  Copyright © 2020 郭子一. All rights reserved.
//

#import "LaunchImageViewController.h"

@interface LaunchImageViewController ()

@property (nonatomic, strong) UIButton *videoBtn;

@end

@implementation LaunchImageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"ISFIRSTLAUNCH"];
    
    UIImageView *img = [[UIImageView alloc] initWithFrame:self.view.bounds];
    img.image = [UIImage imageNamed:@"launchIMG"];
    img.contentMode = UIViewContentModeScaleToFill;
    [self.view addSubview:img];
    
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        if (status == AFNetworkReachabilityStatusNotReachable || status == AFNetworkReachabilityStatusUnknown) {
            //无网络链接
//            NSLog(@"==无网络链接");
            UIButton *videoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            videoBtn.backgroundColor = RGB_VALUE(0x767680);
            [videoBtn setTitle:@"检查网络设置" forState:UIControlStateNormal];
            [videoBtn addTarget:self action:@selector(videoBtnClick) forControlEvents:UIControlEventTouchUpInside];
            [self.view addSubview:videoBtn];
            [self.view bringSubviewToFront:videoBtn];
            [videoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.center.offset(0);
                make.height.mas_equalTo(40);
                make.width.mas_equalTo(140);
            }];
            
        } else {
            //网络链接成功
            NSLog(@"==网络链接成功");
            DVUserManager *manager = [DVUserManager shareManager];
            [manager setRootViewController:manager.tabBarController];
        }
    }];
    [manager startMonitoring];
}

- (void)videoBtnClick
{
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
